import React from 'react'
import PropTypes from 'prop-types'
import { connect } from 'react-redux'
import { withRouter } from 'react-router-dom'
import { checkEditPasswordStatus, checkLogOutStatus,  } from '../actions/user'
import { editPasswordStatus, logOutStatus } from '../reducers/user'
import Index from '../views/Index/index'
import { bindActionCreators } from 'redux'

const IndexContainer = ({editPasswordStatus,logOutStatus,checkEditPasswordStatus,checkLogOutStatus,}) => {    
    return <Index    
        editPasswordStatus={editPasswordStatus}
        logOutStatus={logOutStatus}
        onCheckEditPasswordStatus={(data)=> checkEditPasswordStatus(data)}
        onCheckLogOutStatus={(data)=> checkLogOutStatus(data)}
    />
}

IndexContainer.propTypes = {
    editPasswordStatus: PropTypes.bool,
    logOutStatus: PropTypes.bool,
    checkEditPasswordStatus: PropTypes.func,
    checkLogOutStatus: PropTypes.func,
}

const mapStateToProps  = (state) =>({
    editPasswordStatus:editPasswordStatus(state.user),
    logOutStatus:logOutStatus(state.user),     
})

const mapDispatchToProps = (dispatch) => ({
    checkEditPasswordStatus: bindActionCreators(checkEditPasswordStatus,dispatch),
    checkLogOutStatus: bindActionCreators(checkLogOutStatus,dispatch),
})

export default withRouter(connect(
    mapStateToProps,
    mapDispatchToProps
  )(IndexContainer))